package uit.uthuoc.activity;

import uit.uthuoc.dal.MIMSClassDTO;
import uit.uthuoc.fragment.MIMSClassSearchFragment;
import uit.uthuoc.fragment.SearchResultFragmentInterface;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.util.Log;

public class MIMSClassSearchActivity extends SingleFragmentActivity implements SearchResultFragmentInterface{
	
	public static final String LOG_ID = "uit.uthuoc.activity.MIMSClassSearchActivity";
	private MIMSClassSearchFragment mChildFragment;
	
	@Override
	protected Fragment createFragment() {
		// TODO Auto-generated method stub
		if (mChildFragment == null) 
			mChildFragment = new MIMSClassSearchFragment();
		return mChildFragment;
	}

	@Override
	protected boolean isUpButtonEnable() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void onListItemClickListener(int position) {
		Log.d(LOG_ID, "List item #" + position  +" clicked");
		MIMSClassDTO mims = mChildFragment.getMIMSByPosition(position);
		Log.d(LOG_ID, "MIMS is: " + mims);
		
		Intent intent = new Intent(this, DrugSearchActivity.class);
		intent.putExtra(DrugSearchActivity.EXTRA_MIMS, mims);
		
		startActivity(intent);
	}

}
